home *** CD-ROM | disk | FTP | other *** search
/ Over 1,000 Windows 95 Programs / Over 1000 Windows 95 Programs (Microforum) (Disc 1).iso / 0758 / setup.arv / DISPATCH.CTM < prev    next >
Encoding:
Text File  |  1997-04-10  |  1.9 KB  |  69 lines

  1. type
  2.         keyRec = record
  3.              key theKey : string;
  4.                  theVal : string;
  5.         endRecord
  6. endType
  7.  
  8.  
  9. var
  10.         session : string = '';
  11.         targetFile : string = '';
  12.         itemID : string = '';
  13.         ARec : keyRec;
  14.         subs : table of keyRec;
  15.         items : table of keyRec;
  16.         subItems : byte;
  17.         s : string;
  18. endVar;
  19.  
  20. function strToInt(s : string) : longint;
  21. var
  22.         r : real;
  23. endVar
  24.         val(s, r);
  25.         return r;
  26. endProc
  27.  
  28. procedure main
  29. var
  30.         si : integer;
  31. endVar
  32.         session := fieldParm('SessionID');
  33.         if ((session = '') or (session = '*SeSiOnId*'))
  34.                 getSession; { start a new session and load items table }
  35.         else
  36.                 loadTable(items, session);
  37.         endif;
  38.         targetFile := cgiParm('Physical Path');
  39.         itemID := fieldParm('ItemID');
  40.         loadTable(subs, 'items.db');
  41.         replaceState;
  42.         ARec.theKey := itemID;
  43.         setKeysFromRecord(subs, ARec);
  44.         if (readRecord(subs, ARec))
  45.                 subItems := strToInt(ARec.theVal);
  46.                 for si := 1 to subItems do
  47.                         str(si : 0 : 0, s);
  48.                         ARec.theKey := itemID + s;
  49.                         setKeysFromRecord(items, ARec);
  50.                         if (readRecord(items, ARec))
  51.                                 replaceInMemory('*' + ARec.theKey + '*', ARec.theVal);
  52.                         endif
  53.                 endFor
  54.         endif
  55.         writeFromMemory;
  56. endProc
  57.  
  58. procedure getSession
  59.         session := createTempFile; 
  60.         startSession; { generated by CatMake }
  61. endProc
  62.  
  63. procedure replaceState
  64.         rewriteOutput; { get read of automatic header }
  65.         writeHTTPHeader('text/html');
  66.         fileToMemory(targetFile);
  67.         replaceInMemory('*SeSiOnId*', session);
  68. endProc
  69.